package com.cm.sys.framework.utils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.github.pagehelper.PageInfo;

/***
 * 分页工具类
 * 
 * @author yxq18
 *
 */
@Component
public class PageHelperUtil {

    @SuppressWarnings("rawtypes")
    public static Map getPageinfo(PageInfo pageInfo, int pageSize, List list) {

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("pageCount", pageInfo.getPages());
        data.put("numCount", pageInfo.getTotal());
        data.put("pageIndex", pageInfo.getPageNum());
        data.put("pageSize", pageSize);
        data.put("lists", list);

        return data;
    }

    @SuppressWarnings("rawtypes")
    public Map<String, Object> getPageinfo(PageInfo pageInfo) {

        Map<String, Object> data = new HashMap<String, Object>();
        data.put("pageCount", pageInfo.getPages());
        data.put("numCount", pageInfo.getTotal());
        data.put("pageIndex", pageInfo.getPageNum());
        data.put("pageSize", pageInfo.getPageSize());
        data.put("lists", pageInfo.getList());

        return data;
    }

}
